package com.gxd.redis.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @Author:gxd
 * @Description:
 * @Date: 15:06 2018/1/5
 * @Modified By:
 */
@ConfigurationProperties(prefix = "spring.redis.cluster")
@Component("redisClusterProperties")
public class RedisClusterProperties {
    private static final Logger logger = LoggerFactory.getLogger(RedisClusterProperties.class);

    private List<String> nodes;

    private int maxRedirects;

    private int expireTime;

    private String bizKey;

    /**
     * Get initial collection of known cluster nodes in format {@code host:port}.
     *
     * @return
     */
    public List<String> getNodes() {
        return nodes;
    }

    public void setNodes(List<String> nodes) {
        this.nodes = nodes;
    }

    public int getMaxRedirects() {
        return maxRedirects;
    }

    public void setMaxRedirects(int maxRedirects) {
        this.maxRedirects = maxRedirects;
    }

    public int getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(int expireTime) {
        this.expireTime = expireTime;
    }

    public String getBizKey() {
        return bizKey;
    }

    public void setBizKey(String bizKey) {
        this.bizKey = bizKey;
    }

    @PostConstruct
    private void initialize() {
        logger.debug(
                "RedisClusterProperties initialized - timeout: {}, nodes: {}, maxRedirects: {}",
                 nodes,maxRedirects);
    }
}